package main

import (
	"fabrictask/routes"

	"github.com/gin-gonic/gin"
	"github.com/go-session/gin-session"
)

func main() {
	//gin.SetMode(gin.ReleaseMode)
	r := gin.New()
	r.Use(ginsession.New())
	r.Use(gin.Logger())
	r.Use(gin.Recovery())

	r.StaticFile("/", "./dist/index.html")
	r.StaticFile("/index", "./dist/index.html")
	r.Static("/static", "./dist/static")

	api := r.Group("/v1")
	{

		api.POST("login", routes.Login)
		api.POST("register", routes.Register)
		api.POST("mint", routes.Mint)
		api.POST("issue", routes.Issue)
		api.POST("update", routes.Update)
		api.GET("tasklist", routes.TaskList)
		api.GET("balance", routes.BalanceOf)
		api.GET("logout", routes.LogOut)
	}
	r.Use(gin.Logger())
	r.Use(gin.Recovery())
	r.POST("login", routes.Login)
	r.POST("register", routes.Register)
	r.POST("mint", routes.Mint)
	r.POST("issue", routes.Issue)
	r.POST("update", routes.Update)
	r.GET("tasklist", routes.TaskList)
	r.GET("balance", routes.BalanceOf)
	r.GET("logout", routes.LogOut)

	r.Run(":8181")
}
